import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '项目名称',
    align: "center",
    dataIndex: 'name'
  },
  {
    title: '立项日期',
    align: "center",
    dataIndex: 'approvalDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '项目编号',
    align: "center",
    dataIndex: 'no'
  },
  {
    title: '负责人',
    align: "center",
    dataIndex: 'principal'
  },
  {
    title: '状态',
    align: "center",
    dataIndex: 'status_dictText'
  },
  {
    title: '项目文号',
    align: "center",
    dataIndex: 'approvalNum'
  },
  {
    title: '历史负责人',
    align: "center",
    dataIndex: 'oldPersonCharge'
  },
  {
    title: '负责人编码',
    align: "center",
    dataIndex: 'sysUserCode'
  },
  {
    title: '流程ID',
    align: "center",
    dataIndex: 'procInsId'
  },
  {
    title: '银行帐户ID',
    align: "center",
    dataIndex: 'bankAccountId'
  },
  {
    title: '归档标志',
    align: "center",
    dataIndex: 'hisFlag_dictText'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "项目名称",
    field: 'name',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "立项日期",
    field: "approvalDate",
    component: 'RangePicker',
    //colProps: {span: 6},
  },
  {
    label: "项目编号",
    field: 'no',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "负责人",
    field: 'principal',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "归档标志",
    field: 'hisFlag',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "his_flag"
    },
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '项目名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入项目名称!'},
             ];
    },
  },
  {
    label: '立项日期',
    field: 'approvalDate',
    component: 'DatePicker',
  },
  {
    label: '项目编号',
    field: 'no',
    component: 'Input',
  },
  {
    label: '负责人',
    field: 'principal',
    component: 'Input',
  },
  {
    label: '状态',
    field: 'status',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "project_status"
    },
  },
  {
    label: '项目文号',
    field: 'approvalNum',
    component: 'Input',
  },
  {
    label: '历史负责人',
    field: 'oldPersonCharge',
    component: 'Input',
  },
  {
    label: '负责人编码',
    field: 'sysUserCode',
    component: 'Input',
  },
  {
    label: '流程ID',
    field: 'procInsId',
    component: 'Input',
  },
  {
    label: '银行帐户ID',
    field: 'bankAccountId',
    component: 'JPopup',
    componentProps: ({ formActionType }) => {
        const {setFieldsValue} = formActionType;
        return{
            setFieldsValue:setFieldsValue,
            code:"zc_account_info",
            fieldConfig: [
                { source: 'id', target: 'bankAccountId' },
                { source: 'name', target: 'procInsId' },
            ],
            multi:true
        }
    },

  },
  {
    label: '归档标志',
    field: 'hisFlag',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "his_flag"
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  name: {title: '项目名称',order: 0,view: 'text', type: 'string',},
  approvalDate: {title: '立项日期',order: 1,view: 'date', type: 'string',},
  no: {title: '项目编号',order: 2,view: 'text', type: 'string',},
  principal: {title: '负责人',order: 3,view: 'text', type: 'string',},
  status: {title: '状态',order: 4,view: 'radio', type: 'string',},
  approvalNum: {title: '项目文号',order: 5,view: 'text', type: 'string',},
  oldPersonCharge: {title: '历史负责人',order: 6,view: 'text', type: 'string',},
  sysUserCode: {title: '负责人编码',order: 7,view: 'text', type: 'string',},
  procInsId: {title: '流程ID',order: 8,view: 'text', type: 'string',},
  bankAccountId: {title: '银行帐户ID',order: 9,view: 'popup', type: 'string',code: 'zc_account_info', orgFields: 'id', destFields: 'bankAccountId', popupMulti: false,},
  hisFlag: {title: '归档标志',order: 10,view: 'number', type: 'number',},
};
